home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.ucla.edu!twinsun!not-for-mail
- From: eggert@twinsun.com (Paul Eggert)
- Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
- Subject: Re: float != float and floats as return types
- Date: 1 Feb 1996 09:40:19 -0800
- Organization: Twin Sun Inc, El Segundo, CA, USA
- Message-ID: <4eqtu3$ddo@der.twinsun.com>
- References: <4ej9lb$mpc@fu-berlin.de> <4elnjj$er4@server2.rz.uni-leipzig.de> <4eqc7l$ugh@godzilla.zeta.org.au>
- NNTP-Posting-Host: der.twinsun.com
-
- bde@zeta.org.au (Bruce Evans) writes:
-
- > a = 1.0;
- > b = FLT_EPSILON / 4.0;
- > c = a + b;
- > assert(c == (float) (a + b));
-
- As far as I can tell the C Standard allows the assertion to either
- succeed or fail, depending on the implementation. The key phrase in
- the standard is ``The values of floating operands and of the results of
- floating expressions may be represented in greater precision and range
- than that required by the type''. So `c' might be represented in more
- bits than `(float) (a + b)' (or vice versa! though this is more
- controversial since it contradicts the Rationale, and it may be
- corrected by the committee soon), and the assertion might fail.
-